package com.yuecai.modules.yc_receiver;

import com.yuecai.modules.yc_receiver_info.service.YcReceiverInfoService;
import com.yuecai.modules.yc_receiver_info.service.dto.YcReceiverInfoQueryCriteria;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* @author dm
* @date 2021-01-27
*/
@Slf4j
@RestController
@RequestMapping("/api/receiver")
public class YcReceiverInfoController {

    private final YcReceiverInfoService ycReceiverInfoService;

    public YcReceiverInfoController(YcReceiverInfoService ycReceiverInfoService) {
        this.ycReceiverInfoService = ycReceiverInfoService;
    }


    /**
     * 查询收货人
     * @param criteria
     * @return
     */
    @GetMapping
    public ResponseEntity<Object> findReceiverInfos(YcReceiverInfoQueryCriteria criteria) throws Exception {
        if (criteria.getUserId()==null){
            throw new Exception("请指定用户！");
        }
        return new ResponseEntity<>(ycReceiverInfoService.queryAll(criteria), HttpStatus.OK);
    }
}